/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Chat;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Menu: helper class for drawing the LTSChat menu
 * @author valiadam
 */
public class Menu
{   
    public String printMenu(HttpServletRequest request)
    {
        String out = new String();
        //different options if logged in:
        if (IsLoggedIn(request))
        {
            out += EditProfileBtn();
            out += ViewChatroomsBtn();
            out += SearchUserBtn();
            out += LogoutBtn();
        }
        else
        {
            out += LoginBtn();
            out += SignUpBtn();
        }
        return out;
    }   

    private boolean IsLoggedIn(HttpServletRequest request)
    {
        HttpSession session = request.getSession();
        return ((session != null) && (session.getAttribute("username") != null));
    }

    private String EditProfileBtn()
    {
        return "<a href=\"ProfileTServlet\">Profile</a> ";
    }

    private String ViewChatroomsBtn()
    {
       return "<a href=\"ViewChatRoomsTServlet\">Chat Rooms</a> ";
    }

    private String SearchUserBtn()
    {
        return "<a href=\"userselect.html\">Search User</a> ";
    }

    private String LogoutBtn()
    {
        return "<a href=\"LogOutTServlet\">Log Out</a> ";
    }

    private String LoginBtn()
    {
        return "<a href=\"LoginTServlet\">Login</a> ";
    }

    private String SignUpBtn()
    {
        return "<a href=\"SignUpTServlet\">Sign Up</a> ";
    }
}
